package org.anddev.andengine.extension.svg.util.render;
/**
 * @author Eric Depta
 * @since 01:14:00 - 28.02.2011
 */
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;

import org.anddev.andengine.engine.camera.Camera;
import org.anddev.andengine.entity.shape.IShape;
import org.anddev.andengine.entity.shape.Shape;
import org.anddev.andengine.opengl.buffer.BufferObjectManager;
import org.anddev.andengine.opengl.util.GLHelper;

/*
 * !!Only for drawing primitives!!
 * !!not full support!!
 */

public class TriangleShape extends Shape {
	private final TriangleVertexBuffer mVertexBuffer;
	private final float[] mVertices;
	
	public TriangleShape(final float pX, final float pY, final float[] pVertices) {
		super(pX, pY);
		this.mVertices = pVertices;
		mVertexBuffer = new TriangleVertexBuffer(GL11.GL_STATIC_DRAW);
		BufferObjectManager.getActiveInstance().loadBufferObject(this.mVertexBuffer);
		this.updateVertexBuffer();
	}
	
	@Override
	protected void onInitDraw(final GL10 pGL) {
		super.onInitDraw(pGL);
		GLHelper.disableTextures(pGL);
		GLHelper.disableTexCoordArray(pGL);
	}
	
	@Override
	protected void drawVertices(GL10 pGL, Camera pCamera) {
		pGL.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 3);
	}

	@Override
	protected TriangleVertexBuffer getVertexBuffer() {
		return this.mVertexBuffer;
	}

	@Override
	protected boolean isCulled(Camera pCamera) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	protected void onUpdateVertexBuffer() {
		this.getVertexBuffer().update(this.mVertices);
	}

	@Override
	public boolean collidesWith(IShape pOtherShape) {
		return false;
	}

	@Override
	public float getBaseHeight() {
		return 0;
	}

	@Override
	public float getBaseWidth() {
		return 0;
	}

	@Override
	public float getHeight() {
		return 0;
	}

	@Override
	public float getWidth() {
		return 0;
	}

	@Override
	public boolean contains(float pX, float pY) {
		return false;
	}
}
